#!/bin/bash

# 修复环境变量问题
export SHELL="/bin/bash"
export PATH="/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:$HOME/.local/bin:$PATH"

# 加载 bash 配置
if [ -f ~/.bashrc ]; then
  source ~/.bashrc
fi

# 脚本的其余内容...
echo "📁 当前目录: $PWD"
printf "请输入快捷键的第一个字母: "
read key1

printf "请输入快捷键的第二个字母: "
read key2

printf "请输入描述信息: "
read desc

new_config="    { on = [ \"$key1\", \"$key2\" ], run = \"cd $PWD\", desc = \"$desc\" },"

echo -e "\n🎯 即将添加的配置:"
echo "$new_config"
printf "确认添加? [y/N]: "
read confirm

if [ "$confirm" != "y" ] && [ "$confirm" != "Y" ]; then
  echo "操作已取消"
  exit 0
fi

# 备份并添加配置
cp ~/.config/yazi/keymap.toml ~/.config/yazi/keymap.toml.bak

# 使用绝对路径的工具
/usr/bin/sed -i "/# Goto/a $new_config" ~/.config/yazi/keymap.toml

echo "✅ 目录标记已添加"
echo "🔄 重启 Yazi 后生效"
